OpenFlow is a control protocol between an OpenFlow controller (controller for short) and an OpenFlow switching device (switch for short). The controller controls behaviors of the switch mainly by using a flow table. The flow table is stored in the switch, and formed by several flow entries. Each flow entry generally includes match fields and instructions. A match field generally designates information that needs to be matched (which may be information such as various packet header fields or an ID of a port from which the switch receives a packet), and provides a designated value of the information that needs to be matched, where the designated value is used for comparison with an actual value of the information that is of the packet and needs to be matched, and the instructions include multiple types of instructions, which include an action used for instructing to perform an operation on the packet.
After receiving the packet, the switch performs matching between the received packet and a match field of each flow entry in a flow table that needs to be matched (that is, compares the actual value of the information that is of the packet and needs to be matched with a designated value of the match field of each flow entry in the flow table that needs to be matched to determine whether they are the same). If matching between the received packet and a match field of a flow entry is successful (that is, content of the match field of the flow entry is the same as the actual value of the information that is of the packet and needs to be matched), the switch processes the packet according to an instruction in the flow entry for which matching is successful; if matching between the received packet and match fields of all other flow entries in the flow table that needs to be matched fails, and a Table-Miss flow entry (the Table-Miss flow entry is a special flow entry in the OpenFlow flow table, and this flow entry has no match field, that is, matching between this flow entry and all packets can succeed, and this flow entry has a lowest matching priority) exists in the flow table, the switch processes the packet according to the Table-Miss flow entry (for example, the packet may be discarded or sent to the controller for processing), and if there is no Table-Miss flow entry, the switch determines, according to attributes of the flow table, how to process the packet (for example, the packet may be configured to be discarded or sent to the controller for processing). According to the Table-Miss flow entry or the attributes of the flow table, if the packet needs to be sent to the controller, a first OpenFlow message (the first OpenFlow message includes all or some content of the packet on which matching fails) used for indicating that matching fails is sent to the controller. If the controller receives the first OpenFlow message, the controller may deliver a flow entry to the switch by using a second OpenFlow message, so as to instruct the switch to establish a new flow entry in the flow table that needs to be matched, and a designated value that is of information that needs to be matched and is in a match field of the new flow entry matches the actual value of the information that is of the packet and needs to be matched. After establishing the flow entry in the flow table that needs to be matched, the switch may perform matching on the packet again. Independent of the packet reported by the switch, the controller may also directly deliver a third OpenFlow message, so as to instruct the switch to establish a new flow entry in the flow table that needs to be matched.
To reduce OpenFlow messages between a switch and a controller, the prior art provides a switch configuration method, where the method includes: First, a synchronization flow table and a synchronization rule are configured for a designated flow table in a switch, where the synchronization rule is used for converting a flow entry in the designated flow table into a flow entry in the synchronization flow table, thereby implementing synchronization of update operations such as flow entry addition, modification, and deletion between the two flow tables. Then, the switch receives a second or third OpenFlow message delivered by a controller, and adds, modifies, or deletes a flow entry in a flow table designated by the second or third OpenFlow message, and if the flow table designated by the second or third OpenFlow message has a synchronization flow table, the switch updates, in the synchronization flow table, a flow entry corresponding to the flow entry according to the synchronization rule.
The prior art has the following disadvantage: when a flow entry in a designated flow table is updated, a flow entry in a synchronization flow table also needs to be updated synchronously. If a synchronization update fails, the flow entry in the synchronization flow table is not updated, and therefore when matching is performed between a packet and the flow entry in the synchronization flow table, error packet matching is performed. Moreover, a switch needs to maintain a large quantity of flow entries, a large quantity of redundant information exists in flow entries of different flow tables, and system overhead increases as networking scale increases.